;;; init-selectrum.el --- selectrum config
;;; Commentary:
;;; Code:

;; orderless 排序
(use-package orderless
  :defer t
  :config
  (setq completion-styles '(orderless))
  ;; (setq orderless-skip-highlighting (lambda () selectrum-is-active))
  ;; (setq selectrum-highlight-candidates-function #'orderless-highlight-matches)
  )

;; selectrum补全框架
(use-package selectrum
  :defer t
  :diminish
  :hook (after-init . selectrum-mode)
  :config
  (setq selectrum-refine-candidates-function #'orderless-filter)
  (setq selectrum-highlight-candidates-function #'orderless-highlight-matches))

;; marginalia旁注
(use-package marginalia
  :defer t
  :hook (after-init . marginalia-mode)
  :config
  (setq-default marginalia-annotators '(marginalia-annotator-heavy)))

;; selectrum-prescient 推荐
(use-package selectrum-prescient
  :defer t
  :after selectrum
  :config
  (selectrum-prescient-mode +1))


;; savehist保存历史
(use-package savehist
  :defer t
  :init (savehist-mode))

;; consult 补全框架
(use-package consult
  :defer t
  :bind
  (([remap switch-to-buffer] . consult-buffer)
   ([remap switch-to-buffer-other-window] . consult-buffer-other-window)
   ([remap switch-to-buffer-other-frame] . consult-buffer-other-frame)
   ([remap goto-line] . consult-goto-line)))

;; projectile 项目
(use-package projectile
  :defer t
  :hook (after-init . projectile-mode)
  :config
  (setq-default consult-project-root-function 'projectile-project-root)
  (setq-default projectile-mode-line-prefix " Proj")
  (setq-default projectile-completion-system 'selectrum))

;; 目录和项目
(use-package consult-dir
  :defer t
  :after consult
  :config
  (setq consult-dir-project-list-function #'consult-dir-projectile-dirs))

(provide 'init-selectrum)
;;; init-selectrum.el ends here
